package com.mvp.utils;

import android.content.Context;
import android.os.Looper;
import android.text.TextUtils;
import android.widget.Toast;

import com.mvp.base.BaseApplication;


/**
 * ================================================
 * Created by ${chenyuexueer}
 * 时间： 2018/7/6.
 * 说明：
 * ================================================
 */
public class ToastUtil {
    private static boolean isShow = true;//默认显示
    public static Context context;

    /*private控制不应该被实例化*/
    private ToastUtil() {
        throw new UnsupportedOperationException("不能被实例化");
    }

    /**
     * 显示toast
     *
     * @param text
     */
    public static void showToast(String text) {
        if (Looper.myLooper() == Looper.getMainLooper()) {//只允许主线程弹toast
            if (!TextUtils.isEmpty(text)) {
                Toast.makeText(BaseApplication.sContext, text, Toast.LENGTH_SHORT).show();
            }
        }
    }

    /**
     * 显示toast
     *
     * @param text
     */
    public static void showLongToast(String text) {
        if (Looper.myLooper() == Looper.getMainLooper()) {//只允许主线程弹toast
            if (!TextUtils.isEmpty(text)) {
                Toast.makeText(BaseApplication.sContext, text, Toast.LENGTH_LONG).show();
            }
        }
    }

}
